tg-me.com/python_codes/199
Last Update:
#numpy
NumPy
Broadcasting
Broadcasting describes how NumPy automatically brings two arrays with different shapes to a compatible shape during arithmetic operations. Generally, the smaller array is “repeated” multiple times until both arrays have the same shape. Broadcasting is memory-efficient as it doesn’t actually copy the smaller array multiple times.
Code:
import numpy as npOutput:
A = np.array([1, 2, 3])
res = A * 3 # scalar is broadcasted to [3 3 3]
print(res)
# [3 6 9]
Share and Support
@Python_Codes
BY Python Codes

Share with your friend now:
tg-me.com/python_codes/199